package com.yonyou.pmclouds.siteinspection.service.rmiimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.basecom.bp.processor.AuditInfoInsertProcessor;
import com.yonyou.pmclouds.basecom.bp.processor.DocCenterProcessor;
import com.yonyou.pmclouds.basecom.bp.processor.MobileTaskInsertProcessor;
import com.yonyou.pmclouds.basecom.bp.processor.ProjectStatusCheckProcessor;
import com.yonyou.pmclouds.basecom.bp.template.SingleInsertBpTemplate;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.picture.rmiitf.PictureRemoteService;
import com.yonyou.pmclouds.project.processor.UpdateBillCountForInsertProcessor;
import com.yonyou.pmclouds.siteinspection.entity.SiteInspectionVO;
import com.yonyou.pmclouds.siteinspection.mapper.SiteInspectionMapper;
import com.yonyou.pmclouds.siteinspection.process.CountPassRateProcessor;
import com.yonyou.pmclouds.siteinspection.process.SiteInspectionInspectItemProcess;
import com.yonyou.pmclouds.siteinspection.process.SiteInspectionProjectLogPostProcess;
import com.yonyou.pmclouds.siteinspection.rmiitf.SiteInspectionMaintain;
import org.springframework.beans.factory.annotation.Autowired;

@Service(version = ApplicationConsts.APPLICATION_VERSION, interfaceClass = SiteInspectionMaintain.class)
public class SiteInspectionMaintainImpl implements SiteInspectionMaintain {
    @Autowired
    private SiteInspectionMapper mapper;
    @Autowired
    private PictureRemoteService pictureService;
    @Autowired
    private MobileTaskInsertProcessor<SiteInspectionVO> mobileTaskInsertProcessor;
    @Autowired
    private SiteInspectionInspectItemProcess inspectItemProcess;
    @Autowired
    private ProjectStatusCheckProcessor<SiteInspectionVO> projectStatusCheckProcessor;
    @Autowired
    private UpdateBillCountForInsertProcessor.UpdateBillCountForInsertProcessorFactory<SiteInspectionVO> billCountFactory;
    @Autowired
    private SiteInspectionProjectLogPostProcess siteInspectionProjectLogPostProcess;
    @Autowired
    private CountPassRateProcessor countPassRateProcessor;
    @Autowired
    private DocCenterProcessor docCenterProcessor;

    @Override
    public SiteInspectionVO add(SiteInspectionVO vo) throws BusinessException {
        SingleInsertBpTemplate<SiteInspectionVO> bp = new SingleInsertBpTemplate<SiteInspectionVO>(mapper);
//        bp.addBeforeProcessor(new SiteInspectionBeforeAddProcess());
        // 更新审计信息
        bp.addBeforeProcessor(new AuditInfoInsertProcessor<SiteInspectionVO>());
//        bp.addBeforeProcessor(projectStatusCheckProcessor);
//        bp.addBeforeProcessor(countPassRateProcessor);
//        // 生成我发起的
//        bp.addAfterProcessor(mobileTaskInsertProcessor);
//        // 现场检查新增完之后新增表体检查项
//        bp.addAfterProcessor(inspectItemProcess);
//        bp.addAfterProcessor(billCountFactory.getProcessor(vo.getBill_type()));
//        //智能日志
        bp.addAfterProcessor(siteInspectionProjectLogPostProcess);
//        // NCC文档中心
//        bp.addAfterProcessor(docCenterProcessor);
        bp.insert(vo);
        // 新增后上传图片
        pictureService.insertPictureForPub(vo, null);
        return vo;
    }

//

}
